//
//  HNSH_ConfirmOrderGoodsCell.m
//  HNSH_SingleProject
//
//  Created by 李宇廷 on 2023/2/26.
//

#import "HNSH_ConfirmOrderGoodsCell.h"

@interface HNSH_ConfirmOrderGoodsCell ()

/* iconImgV */
@property (nonatomic, strong) UIImageView *iconImgV;
/* nameLabel */
@property (nonatomic, strong) UILabel *nameLabel;
/* specLabel */
@property (nonatomic, strong) UILabel *specLabel;
/* moneyLabel */
@property (nonatomic, strong) UILabel *moneyLabel;
/* countLabel */
@property (nonatomic, strong) UILabel *countLabel;

@end

@implementation HNSH_ConfirmOrderGoodsCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.contentView.backgroundColor = [UIColor appWhiteLabelColor];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self configUI];
    }
    return self;
}

- (void)setModel:(HNSH_ConfirmOrderGoodsModel *)model {
    _model = model;
    [self.iconImgV sd_setImageWithURL:[NSURL URLWithString:model.left_icon]];
    self.nameLabel.text = model.title;
    self.specLabel.text = model.sku_text;
    self.moneyLabel.text = model.price_text;
    self.countLabel.text = model.quantity_text;
}

- (void)configUI {
    [self.contentView addSubview:self.iconImgV];
    [self.contentView addSubview:self.nameLabel];
    [self.contentView addSubview:self.specLabel];
    [self.contentView addSubview:self.moneyLabel];
    [self.contentView addSubview:self.countLabel];
    
    [self.iconImgV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(20);
        make.top.mas_equalTo(8);
        make.width.height.mas_equalTo(90);
    }];
    
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.iconImgV.mas_right).offset(12);
        make.top.equalTo(self.iconImgV.mas_top);
        make.height.mas_equalTo(22);
        make.width.mas_equalTo(kScreenWidth-142);
    }];
    
    [self.specLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.nameLabel.mas_left);
        make.top.equalTo(self.nameLabel.mas_bottom).offset(5);
        make.height.mas_equalTo(16);
        make.width.mas_equalTo(kScreenWidth-142);
    }];
    
    [self.moneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.nameLabel.mas_left);
        make.bottom.equalTo(self.iconImgV.mas_bottom);
        make.height.mas_equalTo(22);
    }];
    
    [self.countLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-20);
        make.bottom.equalTo(self.iconImgV.mas_bottom);
        make.height.mas_equalTo(17);
    }];
}

#pragma mark lazy
- (UIImageView *)iconImgV {
    if (!_iconImgV) {
        _iconImgV = [[UIImageView alloc]init];
    }
    return _iconImgV;
}

- (UILabel *)nameLabel {
    if (!_nameLabel) {
        _nameLabel = [[UILabel alloc]init];
        _nameLabel.text = @"";
        _nameLabel.textColor = [UIColor appBlackLabelColor];
        _nameLabel.font = [UIFont boldSystemFontOfSize:16];
    }
    return _nameLabel;
}

- (UILabel *)specLabel {
    if (!_specLabel) {
        _specLabel = [[UILabel alloc]init];
        _specLabel.text = @"";
        _specLabel.textColor = [UIColor appGrayLabelColor];
        _specLabel.font = [UIFont systemFontOfSize:12];
    }
    return _specLabel;
}

- (UILabel *)moneyLabel {
    if (!_moneyLabel) {
        _moneyLabel = [[UILabel alloc]init];
        _moneyLabel.text = @"";
        _moneyLabel.textColor = [UIColor appGreenColor];
        _moneyLabel.font = [UIFont boldSystemFontOfSize:16];
    }
    return _moneyLabel;
}

- (UILabel *)countLabel {
    if (!_countLabel) {
        _countLabel = [[UILabel alloc]init];
        _countLabel.text = @"";
        _countLabel.textColor = [UIColor appGrayLabelColor];
        _countLabel.font = [UIFont systemFontOfSize:13];
    }
    return _countLabel;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
